<?php #Добавление произвольного блока как аттача к странице
if(isset($_POST['block']))
{	
	$post=$_POST['block'];
	$cache_arr=$cache->get('admin/attach_block_params','get_comment_params','block');
	if(isset($post['get_block_list']))
	{	
		$ajax='<ul class="to_select_list">';
		foreach($cache_arr as $name=>$params)
		{
			$ajax.='<li onclick="page_editor.selectBlock(this,\''.$name.'\')">'.$params['title'].'</li>';	}
		$ajax.='</ul>';
	}elseif(!empty($post['get_block']) && isset($post['index']))
	{
		$block_name=$post['get_block'];
		$field_name='page_edit[attaches][bl'.$post['index'].'][val]';
		if(isset($cache_arr[$block_name]))
		{
			die($load->module('attaches','getBlockForm',array('block_name'=>$block_name,'field_name'=>$field_name))
				.'<input type="hidden" name="page_edit[attaches][bl'.$post['index'].'][name]" value="'.$block_name.'" />
				<input type="hidden" name="page_edit[attaches][bl'.$post['index'].'][type]" value="block" />');
		}
	}
}

